package com.jia.interviewPro;

/**
 * @program: Leetcode
 * @description: https://leetcode-cn.com/problems/the-masseuse-lcci/
 * @author: STU756
 * @create: 2020-09-03 16:10
 */
public class Pro1716 {
    public int massage(int[] nums) {
        /*
         *转态表示: f[i]表示前i个预约最大时间
         *属性：max  f[len]
         *状态转移：  f[i] = max(f[i-1], f[i-2] + nums[i])
         *                       当前不选       选择
         */
        int len;
        if(nums == null || (len = nums.length) == 0) return 0;
        if(len == 1) return nums[0];
        int[] f = new int[len + 1];
        f[0] = 0;
        f[1] = nums[0];
        f[2] = Math.max(nums[0], nums[1]);
        for(int i = 3; i <= len; i++) {
            f[i] = Math.max(f[i-1], f[i-2] + nums[i-1]);
        }
        return f[len];
    }
}
